<?php
    class RedirectorHelper{
		
		protected $parameters = array();
		
        protected function go( $data ){
            header("Location: /".$data);
        }
		
		public function setUrlParameter( $name, $value ){
			$this->$parameters[$name] = $value;
			return $this;
		}
		
		protected function getUrlParameter(){
			$parms = "";
			foreach ( $this->parameters as $key => $value){
				$parms .= $key.'/'.$value.'/' ;
			}
			return $parms;
		}
		
		public function getCurrentController(){
			global $start;
			return $start->_controller;	
		}
		
		public function getCurrentAction(){
			global $start;
			return $start->_action;	
		}
		
		public function goToControllerAction( $vars = array() ){
			$controller	= $vars['controller'] ?: $this->getCurrentController();
			$action 	= $vars['action'] ?: 'index';
						
			$this->goToUrl( $controller.'/'.$action.'/'.$this->getUrlParameter() );
		}
		
		public function goToIndex(){
			$this->go( goToControllerAction ( array ( 'controller' => 'index' ) ) );
		}
		
		public function goToUrl( $url ){
			header("Location: ".$url);
		}
		
    }